/* Fenil Chandarana Fab Academy 2022 Webpage link: https://fabacademy.org/2022/labs/vigyanashram/students/fenil-chandarana/ */ int dir = 2; int stp = 3; int ms1 = 4; int ms2 = 5; int en = 6; void setup() { /*Sets all pin to output; the microcontroller will send them(the pins) bits, it will not expect to receive any bits from thiese pins.*/ pinMode(dir, OUTPUT); pinMode(stp, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(dir, LOW); //Writes the direction to the EasyDriver DIR pin. (HIGH is clockwise). /*Slowly turns the motor 1600 steps*/ for (int i = 0; i < 400; i++) { digitalWrite(stp, HIGH); delayMicroseconds(100); digitalWrite(stp, LOW); delayMicroseconds(100); } digitalWrite(dir, HIGH); //Writes the direction to the EasyDriver DIR pin. (LOW is counter clockwise). /*Turns the motor fast 1600 steps*/ for (int i = 0; i < 400; i++) { digitalWrite(stp, HIGH); delayMicroseconds(1000); digitalWrite(stp, LOW); delayMicroseconds(1000); } digitalWrite(dir, LOW); //Writes the direction to the EasyDriver DIR pin. (HIGH is clockwise). /*Slowly turns the motor 1600 steps*/ for (int i = 0; i < 800; i++) { digitalWrite(stp, HIGH); delayMicroseconds(100); digitalWrite(stp, LOW); delayMicroseconds(100); } digitalWrite(dir, HIGH); //Writes the direction to the EasyDriver DIR pin. (LOW is counter clockwise). /*Turns the motor fast 1600 steps*/ for (int i = 0; i < 800; i++) { digitalWrite(stp, HIGH); delayMicroseconds(1000); digitalWrite(stp, LOW); delayMicroseconds(1000); } digitalWrite(dir, LOW); //Writes the direction to the EasyDriver DIR pin. (HIGH is clockwise). /*Slowly turns the motor 1600 steps*/ for (int i = 0; i < 1200; i++) { digitalWrite(stp, HIGH); delayMicroseconds(100); digitalWrite(stp, LOW); delayMicroseconds(100); } digitalWrite(dir, HIGH); //Writes the direction to the EasyDriver DIR pin. (LOW is counter clockwise). /*Turns the motor fast 1600 steps*/ for (int i = 0; i < 1200; i++) { digitalWrite(stp, HIGH); delayMicroseconds(1000); digitalWrite(stp, LOW); delayMicroseconds(1000); } digitalWrite(dir, LOW); //Writes the direction to the EasyDriver DIR pin. (HIGH is clockwise). /*Slowly turns the motor 1600 steps*/ for (int i = 0; i < 1600; i++) { digitalWrite(stp, HIGH); delayMicroseconds(100); digitalWrite(stp, LOW); delayMicroseconds(100); } digitalWrite(dir, HIGH); //Writes the direction to the EasyDriver DIR pin. (LOW is counter clockwise). /*Turns the motor fast 1600 steps*/ for (int i = 0; i < 1600; i++) { digitalWrite(stp, HIGH); delayMicroseconds(1000); digitalWrite(stp, LOW); delayMicroseconds(1000); } }